package util;

import java.io.*;
import java.util.Properties;

public class ProUtil {
    private Properties properties = new Properties();
    private static volatile ProUtil cfg = null;
    private static final String ERR_MSG = "从配置文件中不能取得传入参数的返回值：";

    private ProUtil() {
        InputStream is = null;

        try {
            is = ProUtil.class.getResourceAsStream("/config.properties");
            BufferedReader bf = new BufferedReader(new InputStreamReader(is, "UTF-8"));
            this.properties.load(bf);
        } catch (Exception var11) {
            var11.printStackTrace();
            System.out.println("Can't read the properties file. ");
        } finally {
            try {
                if (is != null) {
                    is.close();
                }
            } catch (IOException var10) {
                var10.printStackTrace();
            }

        }

    }

    public static ProUtil getInstance() {
        if (cfg == null) {
            Class var0 = ProUtil.class;
            synchronized (ProUtil.class) {
                if (cfg == null) {
                    cfg = new ProUtil();
                }
            }
        }

        return cfg;
    }

    public static String getValue(String key) {
        if (cfg == null) {
            cfg = getInstance();
        }
        if (!cfg.properties.containsKey(key)) {
            return null;
        } else {
            String value = cfg.properties.getProperty(key);
            if (value == null) {
                System.out.println("从配置文件中不能取得传入参数的返回值：:" + key);
            }
            return value;
        }
    }
}
